package com.alan.base.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.google.android.material.tabs.TabLayout;

public class EnableTabLayout extends TabLayout {

    private boolean isTouchEnable;
    public EnableTabLayout(@NonNull Context context) {
        super(context);
        isTouchEnable = true;
    }

    public EnableTabLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        isTouchEnable = true;
    }

    public void setTouchEnable(boolean touchEnable) {
        isTouchEnable = touchEnable;
    }

    public boolean isTouchEnable() {
        return isTouchEnable;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if(!isTouchEnable){
            return true;
        }
        return super.onInterceptTouchEvent(ev);
    }

}
